package com.qiall.bashutil;

import ch.ethz.ssh2.Connection;


public class ScripCommandUtil {

    /**
     *
     * @param connection
     * @param filePath
     * @return 返回单位  byte
     */
    public static long getFileByteSize(Connection connection, String filePath) {
        try {
            String ret = SshScripUtil.execute(connection, "wc -c " + filePath);
            String byteString = ret.split(" ")[0];
            long bytesInteger = Long.parseLong(byteString);
            return bytesInteger;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }

    /**
     * linux 本地cp命令
     * @param connection
     * @param src
     * @param target
     */
   public static  void cpFile(Connection connection,String src ,String target){
       String command="cp "+src+" "+target;
       try {
           SshScripUtil.execute(connection,command);
       } catch (Exception e) {
           e.printStackTrace();
       }
   }

}
